<?php

class Offer extends CActiveRecord
{
	/**
	 * The followings are the available columns in table 'tbl_comment':
	 * @var integer $id
	 * @var string $content
	 * @var integer $status
	 * @var integer $created
	 * @var string $author
	 * @var string $email
	 * @var string $url
	 * @var integer $post_id
	 */
	public $notelink;
	public $location;
	public $ownlocation;

	/**
	 * Returns the static model of the specified AR class.
	 * @return CActiveRecord the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{offer}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('heading, content, comment, location', 'required'),
			array('notelink', 'boolean'),
		);
	}
	/**
	 * Declares attribute labels.
	 */
	public function attributeLabels()
	{
		return array(
			'heading' => 'Titel',
			'content' => 'Anzeige Text',
			'comment' => 'Anzeige Text Detail',
			'notelink'=> 'Facebook Notiz erstellen',
			'location' => 'Lage, Ort',
			
		);
	}
	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
			return array(
		);
	}
        
	public function afterFind() {
            parent::afterFind();
            //$this->name='Xxxxx Xxx';
        }

	/**
	 * Generates a salt that can be used to generate a password hash.
	 * @return string the salt
	 */	
	public function beforeSave() {
    	if ($this->isNewRecord){
			$now=new CDbExpression("NOW()");
        	$this->created = $now;
        	}
    	return parent::beforeSave();
	}


}

